<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /*
     * User  users  myuser
     * Post  posts
     *
     * */

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */

    // 白名单 规定哪些字段是容许填充的;
    protected $guarded = [
       'id'
    ];



    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    // 创建  多对多关联关系
    public function favorites(){
        return $this->belongsToMany(Post::class,"favorites","user_id","post_id");
    }


    // 创建  一对多关联关系
    public function posts(){
        return $this->hasMany('App\Post');
    }
    public function test(){

    }

}
